// TradeRecordMapper.java (数据访问层)
package com.ywb.mapper;

import com.ywb.pojo.TradeRecord;
import com.ywb.pojo.TradeRecordQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface TradeRecordMapper {

    @Select("SELECT * FROM trade_record ORDER BY trade_id ")
    List<TradeRecord> findAll();

    @Delete("DELETE FROM trade_record WHERE trade_id = #{id}")
    void deleteById(Long id);

    @Insert("INSERT INTO trade_record(" +
            "commodity_id, country_id, trade_type, total_amount, tariff_rate, " +
            "trade_date, create_time, update_time" +
            ") VALUES (" +
            "#{commodityId}, #{countryId}, #{tradeType}, #{totalAmount}, #{tariffRate}, " +
            "#{tradeDate}, #{createTime}, #{updateTime}" +
            ")")
    void insert(TradeRecord tradeRecord);

    @Select("SELECT * FROM trade_record WHERE trade_id = #{id}")
    TradeRecord getById(Long id);


    void update(TradeRecord tradeRecord);

    List<TradeRecord> list(TradeRecordQueryParam tradeRecordQueryParam);

    void deleteByIds(List<Integer> ids);

    List<Map<String, Object>> countTypeData();

    List<Map<String, Object>> countInTradeData();

    List<Map<String, Object>> countOutTradeData();

    List<Map<String, Object>> countInCoutryTradeData();

    List<Map<String, Object>> countOutCoutryTradeData();

    List<Map<String, Object>> countCategoryData();
}